package day4.game;

import java.util.Objects;

/**
 * ClassName：Card
 *
 * @Author：小鱼
 * @Create：2025-08-14 14:43
 */
public class Card implements Comparable<Card>{
    //花色
    private String color;
    //点数
    private String number;
    //权重
    private int weight;

    //构造函数
    public Card() {
    }

    public Card(String color, String number, int weight) {
        this.color = color;
        this.number = number;
        this.weight = weight;
    }
    //get，set方法

    public String getColor() {
        return color;
    }

    public void setColor(String color) {
        this.color = color;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public int getWeight() {
        return weight;
    }

    public void setWeight(int weight) {
        this.weight = weight;
    }
    //重写方法

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Card card = (Card) o;
        return weight == card.weight && Objects.equals(color, card.color) && Objects.equals(number, card.number);
    }

    @Override
    public int hashCode() {
        return Objects.hash(color, number, weight);
    }

    @Override
    public String toString() {
        return  color + number ;
    }

    @Override
    public int compareTo(Card o) {
        return Integer.compare(this.weight, o.weight);
    }
}
